package edu.gyc.objecthomework;

/**
 File name: Counter.java
 
 Class to count things: records a count that is a nonnegative whole number.
 Can be set to zero, incremented by 1, and decremented by 1.
 
 Author: Lew Rakocy
 email address: Lrakocy@devrycols.edu
 Date: <2/20/99>
 Changes: 03/9/2003 Made comments like text examples. 
*/
public class Counter
{
    private int value;

    /**
     Sets the counter to zero
    */

    public void setZero()
    {
        value = 0;
    }

    /**
     Increment counter by one
    */

    public void increment()
    {
        value++;
    }

    /**
     Decrements value by one, but does not go below zero
    */

    public void decrement()
    {
        if(value > 0)
            value--;
    }

    /**
     Returns the counter's value.
    */

    public int countIs()
    {
        return value;
    }

    /**
     Displays the counter's value.
    */

    public void printCounter()
    {
        System.out.println("Counter value = " + value);
    }
 }